package lily.phs.epidemic;


import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;

import org.json.JSONException;
import org.json.JSONObject;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;

import lily.phs.urh.R;
import lily.ui.control.MyPopupWindow;
import lily.phs.child.ChildScrollActivity;
import lily.phs.database.Constants;
import lily.phs.object.EpidemicRecord;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.text.InputType;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;

public class Epidemic extends Activity implements OnClickListener,OnFocusChangeListener,Constants{//            
	Button leftBtn;
    Button rightBtn ;
    Button rightBtn2,rightBtn0;
    AlertDialog ad;
	private EditText et_number,et_name,et_parent_name,et_perid,et_born,et_full_born,et_work,et_phone,et_housenumber,et_job_other,
	                 et_ill_date,et_diag_date,et_diag_time,et_die_date,et_other,et_disease_name,et_reason,et_orgnization,et_connect_phone,
	                 et_report,et_fill_date,et_remark,et_province,et_city,et_country,et_town,et_village;
	private RadioGroup r1,r2,r3,r4,r5,r6;
	private RadioButton r1_1,r1_2,r2_1,r2_2,r3_1,r3_2,r3_3,r4_1,r4_2,r4_3,r4_4,r4_5,r4_6,job_1,job_2,job_3,job_4,job_5,
	                    job_6,job_7,job_8,job_9,job_10,job_11,job_12,job_13,job_14,job_15,job_16,job_17,job_18,
	                    r5_1,r5_2,r5_3,r5_4,r6_1,r6_2,r7_1,r7_2,b1,b2,b3_1,b3_2,b3_3,b3_4,b3_5,b4,b5,b6,b7,b8,b9,b10,
	                    b11_1,b11_2,b11_3,b12_1,b12_2,b13_1,b13_2,b13_3,b13_4,b14_1,b14_2,b15,b16,b17,b18,b19,b20,b21,
	                    b22_1,b22_2,b22_3,b22_4,b22_5,b23,b24,b25_1,b25_2,b25_3,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10;
	private List<RadioButton> j ,b;
	private MyPopupWindow mPopupWindow;
	private EpidemicRecord ep;
	private int indiid,num=0,num1=0 ;
	private ProgressDialog mpDialog;
	private String name,paraentname,born,workunit,phone,perid,fullborn,province,city,country,town,village,housenumber,
	               job_other,illdate,diagdate,diagtime,diedate,other,illname,reason,unit, connect_phone,report,filldate,remark;
    private int id,category,sex,fullunit,area,job,classification_a,classification_b,disease_a;
	private int en,check;
    public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
		setContentView(R.layout.epidemic);
		getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.i_title_2);
		// TODO Auto-generated constructor stub
		leftBtn = (Button) findViewById(R.id.title_left_btn);
        rightBtn0 = (Button) findViewById(R.id.title_right_btn0);
        rightBtn = (Button) findViewById(R.id.title_right_btn);
        rightBtn2 = (Button) findViewById(R.id.title_right_btn2);
		    leftBtn.setText("后退");
	        rightBtn.setText("保存");
	        rightBtn2.setText("提交");
	        rightBtn0.setText("修改");
	        rightBtn0.setVisibility(View.INVISIBLE);
	        leftBtn.setOnClickListener(this);
	        rightBtn.setOnClickListener(this);
	        rightBtn2.setOnClickListener(this); 
	        Intent i=this.getIntent();
			Bundle bd=i.getExtras();
			indiid=bd.getInt("Profile_id");
	  findViewsById();
	  disease();
	  mpDialog = new ProgressDialog(Epidemic.this);  
		mpDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);//设置风格为圆形进度条  
		mpDialog.setMessage("正在加载...");  
		mpDialog.setIndeterminate(false);//设置进度条是否为不明确  
		mpDialog.setCancelable(true);//设置进度条是否可以按退回键取消  
		mpDialog.show();
		new myThread(handler,"",1).start();	   

		
	}
   

	public void findViewsById() {
		et_number = (EditText)this.findViewById(R.id.ep_number);
		et_name = (EditText)this.findViewById(R.id.ep_name);
		et_province =(EditText)this.findViewById(R.id.ep_province);
		et_city=(EditText)this.findViewById(R.id.ep_city);
		et_country=(EditText)this.findViewById(R.id.ep_country);
		et_town=(EditText)this.findViewById(R.id.ep_town);
		et_village=(EditText)this.findViewById(R.id.ep_village);
		et_parent_name = (EditText)this.findViewById(R.id.ep_parent_name);
		et_perid = (EditText)this.findViewById(R.id.ep_person_id);
		et_born = (EditText)this.findViewById(R.id.ep_born);
		et_born.setInputType(InputType.TYPE_NULL);//不显示虚拟键盘
		et_born.setOnClickListener(this);
		et_born.setOnFocusChangeListener(this);
		et_full_born = (EditText)this.findViewById(R.id.ep_full_born);
		et_full_born.setOnFocusChangeListener(this);
        et_full_born.setOnClickListener(this);
		et_work = (EditText)this.findViewById(R.id.ep_workunit);
	    et_work.setOnClickListener(this);
		et_phone = (EditText)this.findViewById(R.id.ep_phone);
		et_phone.setOnClickListener(this);
		et_housenumber = (EditText)this.findViewById(R.id.ep_housenumber);
		et_housenumber.setOnClickListener(this);
		et_job_other = (EditText)this.findViewById(R.id.ep_job_other);
		et_job_other.setOnFocusChangeListener(this);
        et_job_other.setOnClickListener(this);
		et_ill_date = (EditText)this.findViewById(R.id.ep_ill_date);
		et_ill_date.setInputType(InputType.TYPE_NULL);//不显示虚拟键盘
		et_ill_date.setOnClickListener(this);
		et_ill_date.setOnFocusChangeListener(this);
		et_diag_date = (EditText)this.findViewById(R.id.ep_diag_date);
		et_diag_date.setInputType(InputType.TYPE_NULL);//不显示虚拟键盘
		et_diag_date.setOnClickListener(this);
		et_diag_date.setOnFocusChangeListener(this);
		et_diag_time= (EditText)this.findViewById(R.id.ep_diag_time);
		et_diag_time.setOnClickListener(this);
		et_die_date = (EditText)this.findViewById(R.id.ep_die_date);
		et_die_date.setInputType(InputType.TYPE_NULL);//不显示虚拟键盘
		et_die_date.setOnClickListener(this);
		et_die_date.setOnFocusChangeListener(this);
		et_other = (EditText)this.findViewById(R.id.ep_otherill);
		et_other.setOnFocusChangeListener(this);
        et_other.setOnClickListener(this);
		et_disease_name = (EditText)this.findViewById(R.id.ep_ill_name);
		et_disease_name.setOnClickListener(this);
		et_reason = (EditText)this.findViewById(R.id.ep_reason);
		et_reason.setOnClickListener(this);
		et_orgnization = (EditText)this.findViewById(R.id.ep_report_unit);
		et_orgnization.setOnClickListener(this);
		et_connect_phone = (EditText)this.findViewById(R.id.ep_phone2);
		et_connect_phone.setOnClickListener(this);
		et_report = (EditText)this.findViewById(R.id.ep_report_person);
		et_report.setOnClickListener(this);
		et_fill_date = (EditText)this.findViewById(R.id.ep_fill_date);
		et_fill_date.setInputType(InputType.TYPE_NULL);//不显示虚拟键盘
		et_fill_date.setOnClickListener(this);
		et_remark = (EditText)this.findViewById(R.id.ep_remark);
		et_remark.setOnClickListener(this);
		r1=(RadioGroup)this.findViewById(R.id.ep_r1);
		r2=(RadioGroup)this.findViewById(R.id.ep_r2);
		r3=(RadioGroup)this.findViewById(R.id.ep_r3);
		r4=(RadioGroup)this.findViewById(R.id.ep_r4);
		r5=(RadioGroup)this.findViewById(R.id.ep_r5);
		r6=(RadioGroup)this.findViewById(R.id.ep_r6);
		r1_1=(RadioButton)this.findViewById(R.id.ep_r1_1);
		r1_2=(RadioButton)this.findViewById(R.id.ep_r1_2);
		r2_1=(RadioButton)this.findViewById(R.id.ep_r2_1);
		r2_2=(RadioButton)this.findViewById(R.id.ep_r2_2);
		r3_1=(RadioButton)this.findViewById(R.id.ep_r3_1);
		r3_2=(RadioButton)this.findViewById(R.id.ep_r3_2);
		r3_3=(RadioButton)this.findViewById(R.id.ep_r3_3);
		r4_1=(RadioButton)this.findViewById(R.id.ep_r4_1);
		r4_2=(RadioButton)this.findViewById(R.id.ep_r4_2);
		r4_3=(RadioButton)this.findViewById(R.id.ep_r4_3);
		r4_4=(RadioButton)this.findViewById(R.id.ep_r4_4);
		r4_5=(RadioButton)this.findViewById(R.id.ep_r4_5);
		r4_6=(RadioButton)this.findViewById(R.id.ep_r4_6);
		job_1=(RadioButton)this.findViewById(R.id.ep_job_1);
		job_1.setOnClickListener(this);
		job_2=(RadioButton)this.findViewById(R.id.ep_job_2);
		job_2.setOnClickListener(this);
		job_3=(RadioButton)this.findViewById(R.id.ep_job_3);
		job_3.setOnClickListener(this);
		job_4=(RadioButton)this.findViewById(R.id.ep_job_4);
		job_4.setOnClickListener(this);
		job_5=(RadioButton)this.findViewById(R.id.ep_job_5);
		job_5.setOnClickListener(this);
		job_6=(RadioButton)this.findViewById(R.id.ep_job_6);
		job_6.setOnClickListener(this);
		job_7=(RadioButton)this.findViewById(R.id.ep_job_7);
		job_7.setOnClickListener(this);
		job_8=(RadioButton)this.findViewById(R.id.ep_job_8);
		job_8.setOnClickListener(this);
		job_9=(RadioButton)this.findViewById(R.id.ep_job_9);
		job_9.setOnClickListener(this);
		job_10=(RadioButton)this.findViewById(R.id.ep_job_10);
		job_10.setOnClickListener(this);
		job_11=(RadioButton)this.findViewById(R.id.ep_job_11);
		job_11.setOnClickListener(this);
		job_12=(RadioButton)this.findViewById(R.id.ep_job_12);
		job_12.setOnClickListener(this);
		job_13=(RadioButton)this.findViewById(R.id.ep_job_13);
		job_13.setOnClickListener(this);
		job_14=(RadioButton)this.findViewById(R.id.ep_job_14);
		job_14.setOnClickListener(this);
		job_15=(RadioButton)this.findViewById(R.id.ep_job_15);
		job_15.setOnClickListener(this);
		job_16=(RadioButton)this.findViewById(R.id.ep_job_16);
		job_16.setOnClickListener(this);
		job_17=(RadioButton)this.findViewById(R.id.ep_job_17);
		job_17.setOnClickListener(this);
		job_18=(RadioButton)this.findViewById(R.id.ep_job_18);
		job_18.setOnClickListener(this);
		r5_1=(RadioButton)this.findViewById(R.id.ep_r5_1);
		r5_2=(RadioButton)this.findViewById(R.id.ep_r5_2);
		r5_3=(RadioButton)this.findViewById(R.id.ep_r5_3);
		r5_4=(RadioButton)this.findViewById(R.id.ep_r5_4);
		r6_1=(RadioButton)this.findViewById(R.id.ep_r6_1);
		r6_2=(RadioButton)this.findViewById(R.id.ep_r6_2);
		r7_1=(RadioButton)this.findViewById(R.id.ep_r7_1);
	    r7_1.setOnClickListener(this);
		r7_2=(RadioButton)this.findViewById(R.id.ep_r7_2);
		r7_2.setOnClickListener(this);
		b1=(RadioButton)this.findViewById(R.id.ep_b1);
		b1.setOnClickListener(this);
		b2=(RadioButton)this.findViewById(R.id.ep_b2);
		b2.setOnClickListener(this);
		b3_1=(RadioButton)this.findViewById(R.id.ep_b3_1);
		b3_1.setOnClickListener(this);
		b3_2=(RadioButton)this.findViewById(R.id.ep_b3_2);
		b3_2.setOnClickListener(this);
		b3_3=(RadioButton)this.findViewById(R.id.ep_b3_3);
		b3_3.setOnClickListener(this);
		b3_4=(RadioButton)this.findViewById(R.id.ep_b3_4);
		b3_4.setOnClickListener(this);
		b3_5=(RadioButton)this.findViewById(R.id.ep_b3_5);
		b3_5.setOnClickListener(this);
		b4=(RadioButton)this.findViewById(R.id.ep_b4);
		b4.setOnClickListener(this);
		b5=(RadioButton)this.findViewById(R.id.ep_b5);
		b5.setOnClickListener(this);
		b6=(RadioButton)this.findViewById(R.id.ep_b6);
		b6.setOnClickListener(this);
		b7=(RadioButton)this.findViewById(R.id.ep_b7);
		b7.setOnClickListener(this);
		b8=(RadioButton)this.findViewById(R.id.ep_b8);
		b8.setOnClickListener(this);
		b9=(RadioButton)this.findViewById(R.id.ep_b9);
		b9.setOnClickListener(this);
		b10=(RadioButton)this.findViewById(R.id.ep_b10);
		b10.setOnClickListener(this);
		b11_1=(RadioButton)this.findViewById(R.id.ep_b11_1);
		b11_1.setOnClickListener(this);
		b11_2=(RadioButton)this.findViewById(R.id.ep_b11_2);
		b11_2.setOnClickListener(this);
		b11_3=(RadioButton)this.findViewById(R.id.ep_b11_3);
		b11_3.setOnClickListener(this);
		b12_1=(RadioButton)this.findViewById(R.id.ep_b12_1);
		b12_1.setOnClickListener(this);
		b12_2=(RadioButton)this.findViewById(R.id.ep_b12_2);
		b12_2.setOnClickListener(this);
		b13_1=(RadioButton)this.findViewById(R.id.ep_b13_1);
		b13_1.setOnClickListener(this);
		b13_2=(RadioButton)this.findViewById(R.id.ep_b13_2);
		b13_2.setOnClickListener(this);
		b13_3=(RadioButton)this.findViewById(R.id.ep_b13_3);
		b13_3.setOnClickListener(this);
		b13_4=(RadioButton)this.findViewById(R.id.ep_b13_4);
		b13_4.setOnClickListener(this);
		b14_1=(RadioButton)this.findViewById(R.id.ep_b14_1);
		b14_1.setOnClickListener(this);
		b14_2=(RadioButton)this.findViewById(R.id.ep_b14_2);
		b14_2.setOnClickListener(this);
		b15=(RadioButton)this.findViewById(R.id.ep_b15);
		b15.setOnClickListener(this);
		b16=(RadioButton)this.findViewById(R.id.ep_b16);
		b16.setOnClickListener(this);
		b17=(RadioButton)this.findViewById(R.id.ep_b17);
		b17.setOnClickListener(this);
		b18=(RadioButton)this.findViewById(R.id.ep_b18);
		b18.setOnClickListener(this);
		b19=(RadioButton)this.findViewById(R.id.ep_b19);
		b19.setOnClickListener(this);
		b20=(RadioButton)this.findViewById(R.id.ep_b20);
		b20.setOnClickListener(this);
		b21=(RadioButton)this.findViewById(R.id.ep_b21);
		b21.setOnClickListener(this);
		b22_1=(RadioButton)this.findViewById(R.id.ep_b22_1);
		b22_1.setOnClickListener(this);
		b22_2=(RadioButton)this.findViewById(R.id.ep_b22_2);
		b22_2.setOnClickListener(this);
		b22_3=(RadioButton)this.findViewById(R.id.ep_b22_3);
		b22_3.setOnClickListener(this);
		b22_4=(RadioButton)this.findViewById(R.id.ep_b22_4);
		b22_4.setOnClickListener(this);
		b22_5=(RadioButton)this.findViewById(R.id.ep_b22_5);
		b22_5.setOnClickListener(this);
		b23=(RadioButton)this.findViewById(R.id.ep_b23);
		b23.setOnClickListener(this);
		b24=(RadioButton)this.findViewById(R.id.ep_b24);
		b24.setOnClickListener(this);
		b25_1=(RadioButton)this.findViewById(R.id.ep_b25_1);
		b25_1.setOnClickListener(this);
		b25_2=(RadioButton)this.findViewById(R.id.ep_b25_2);
		b25_2.setOnClickListener(this);
		b25_3=(RadioButton)this.findViewById(R.id.ep_b25_3);
		b25_3.setOnClickListener(this);
		c1=(RadioButton)this.findViewById(R.id.ep_c1);
		c1.setOnClickListener(this);
		c2=(RadioButton)this.findViewById(R.id.ep_c2);
		c2.setOnClickListener(this);
		c3=(RadioButton)this.findViewById(R.id.ep_c3);
		c3.setOnClickListener(this);
		c4=(RadioButton)this.findViewById(R.id.ep_c4);
		c4.setOnClickListener(this);
		c5=(RadioButton)this.findViewById(R.id.ep_c5);
		c5.setOnClickListener(this);
		c6=(RadioButton)this.findViewById(R.id.ep_c6);
		c6.setOnClickListener(this);
		c7=(RadioButton)this.findViewById(R.id.ep_c7);
		c7.setOnClickListener(this);
		c8=(RadioButton)this.findViewById(R.id.ep_c8);
		c8.setOnClickListener(this);
		c9=(RadioButton)this.findViewById(R.id.ep_c9);
		c9.setOnClickListener(this);
		c10=(RadioButton)this.findViewById(R.id.ep_c10);
		c10.setOnClickListener(this);
				
	}
//填充view
	public void initView() {
		initialState();
		if(ep.getIndi_en()==1){
			enable();

		}
		
		System.out.println("state="+ep.getIndi_en()+ep.getIndi_check());
		
		if(ep.getIndi_name()!=null){
			et_name.setText(ep.getIndi_name());	
			name=ep.getIndi_name();
		}
		if(ep.getIndi_id()!=0){
			et_number.setText(String.valueOf(ep.getIndi_id()));	
			id=ep.getIndi_id();
		}
		if(ep.getIndi_report()!=null){
			et_report.setText(ep.getIndi_report());
			report=ep.getIndi_report();
		}
		if(ep.getIndi_fill_date()!=null){
			et_fill_date.setText(ep.getIndi_fill_date());	
			filldate=ep.getIndi_fill_date();
		}
		if(ep.getIndi_province()!=null){
			et_province.setText(ep.getIndi_province());
			province=ep.getIndi_province();
		}
		if(ep.getIndi_city()!=null){
			et_city.setText(ep.getIndi_city());
			city=ep.getIndi_city();
		}
		if(ep.getIndi_country()!=null){
			et_country.setText(ep.getIndi_country());
			country=ep.getIndi_country();
		}
		if(ep.getIndi_town()!=null){
			et_town.setText(ep.getIndi_town());
			town=ep.getIndi_town();
		}
		if(ep.getIndi_village()!=null){
			et_village.setText(ep.getIndi_village());
			village=ep.getIndi_village();
		}

		et_name.setEnabled(false);
		et_number.setEnabled(false);
		et_fill_date.setEnabled(false);
		et_province.setEnabled(false);
		et_city.setEnabled(false);
		et_country.setEnabled(false);
//		et_town.setEnabled(false);
		
		
		String temp ="";
		int itemp =-1;
		
		itemp = ep.getIndi_category();
		category=ep.getIndi_category();
		switch(itemp){
		case 1:
			r1.check(0);
			r1_1.setChecked(true);
			break;
		case 2:
			r1.check(1);
			r1_2.setChecked(true);
			break;
		}
		
		temp = ep.getIndi_parent_name();
		paraentname=temp;
		if(temp.length()>0){
			et_parent_name.setText(temp);
			
		}
		
		temp = ep.getIndi_perid();
		perid=temp;
		if(temp.length()>0){
			et_perid.setText(temp);
			
		}
		
		itemp = ep.getIndi_sex();
		sex=itemp;
		switch(itemp){
		case 1:
			r2.check(0);
			r2_1.setChecked(true);
			break;
		case 2:
			r2.check(1);
			r2_2.setChecked(true);
			break;
		}
		
		temp = ep.getIndi_born();
		born=temp;
		if(temp.length()>0){
			et_born.setText(temp);
			
		}
		
		temp = ep.getIndi_full_born();
		fullborn=temp;
		if(temp.length()>0){
			et_full_born.setText(temp);
		}
		
		itemp = ep.getIndi_full_unit();
		fullunit=itemp;
		switch(itemp){
		case 1:
			r3.check(0);
			r3_1.setChecked(true);
			break;
		case 2:
			r3.check(1);
			r3_2.setChecked(true);
			break;
		case 3:
			r3.check(2);
			r3_3.setChecked(true);
			break;	
		}
		
		temp = ep.getIndi_work();
		workunit=temp;
		if(temp.length()>0){
			et_work.setText(temp);
			
		}
		
		temp = ep.getIndi_phone();
		phone=temp;
		if(temp.length()>0){
			et_phone.setText(temp);
			
		}
		
		itemp = ep.getIndi_area();
		area=itemp;
		switch(itemp){
		case 1:
			r4.check(0);
			r4_1.setChecked(true);
			break;
		case 2:
			r4.check(1);
			r4_2.setChecked(true);
			break;
		case 3:
			r4.check(2);
			r4_3.setChecked(true);
			break;	
		case 4:
			r4.check(3);
			r4_4.setChecked(true);
			break;
		case 5:
			r4.check(4);
			r4_5.setChecked(true);
			break;
		case 6:
			r4.check(5);
			r4_6.setChecked(true);
			break;	
		}
		
		temp = ep.getIndi_number();
		housenumber=temp;
		if(temp.length()>0){
			et_housenumber.setText(temp);			
		}
		
		itemp = ep.getIndi_job();
		job=itemp;
		  job();
		for(int i=0;i<18;i++){
			if((i+1)==itemp){
				j.get(i).setChecked(true);
			}
		}
		
		temp = ep.getIndi_job_other();
		job_other=temp;
		if(temp.length()>0){
			et_job_other.setText(temp);
		}
		
		itemp = ep.getIndi_classification_a();
		classification_a=itemp;
		switch(itemp){
		case 1:
			r5.check(0);
			r5_1.setChecked(true);
			break;
		case 2:
			r5.check(1);
			r5_2.setChecked(true);
			break;
		case 3:
			r5.check(2);
			r5_3.setChecked(true);
			break;	
		case 4:
			r5.check(3);
			r5_4.setChecked(true);
			break;	
			
		}
		
		itemp = ep.getIndi_classification_b();
		classification_b=itemp;
		switch(itemp){
		case 1:
			r6.check(0);
			r6_1.setChecked(true);
			break;
		case 2:
			r6.check(1);
			r6_2.setChecked(true);
			break;
		}	
		
		temp = ep.getIndi_ill_date();
		illdate=temp;
		if(temp.length()>0){
			et_ill_date.setText(temp);
		}
		
		temp = ep.getIndi_diagnose_date();
		diagdate=temp;
		if(temp.length()>0){
			et_diag_date.setText(temp);
		}
		temp = ep.getIndi_diagnose_time();
		diagtime=temp;
		if(temp.length()>0){
			et_diag_time.setText(temp);
		}
		
		temp = ep.getIndi_die_date();
		diedate=temp;
		if(temp.length()>0){
			et_die_date.setText(temp);
		}
		
		itemp = ep.getIndi_disease_a();
		disease_a=itemp;
		for(int i=0;i<54;i++){
			if((i+1)==itemp){
				b.get(i).setChecked(true);
			}
		}    
	        
	    temp = ep.getIndi_other();
	    other=temp;
			if(temp.length()>0){
				et_other.setText(temp);
			}
	   temp = ep.getIndi_disease_name();
	   illname=temp;
			if(temp.length()>0){
				et_disease_name.setText(temp);
			}		
	    
	    temp = ep.getIndi_reason();
	    reason=temp;
			if(temp.length()>0){
				et_reason.setText(temp);
			}
			temp = ep.getIndi_orgnization();
			unit=temp;
			if(temp.length()>0){
				et_orgnization.setText(temp);
			}
			temp = ep.getIndi_connect_phone();
			connect_phone=temp;
			if(temp.length()>0){
				et_connect_phone.setText(temp);
			}
		temp = ep.getIndi_remark();
		remark=temp;
			if(temp.length()>0){
				et_remark.setText(temp);
			}
	}
	
	/**
	 * 初始时显示空表：横线为空，所有选择项未选中
	 */
	private void initialState() {
		et_number.setText("");
		et_name .setText("");
		et_parent_name .setText("");
		et_perid .setText("");
		et_born .setText("");
		et_full_born .setText("");
		et_work .setText("");
		et_phone.setText("");
		et_housenumber.setText("");
		et_job_other.setText("");
		et_ill_date .setText("");
		et_diag_date .setText("");
		et_diag_time .setText("");
		et_die_date .setText("");
		et_other .setText("");
		et_disease_name .setText("");
		et_reason.setText("");
		et_orgnization .setText("");
		et_connect_phone .setText("");
		et_report.setText("");
		et_fill_date .setText("");
		et_remark .setText("");
		r1_1.setChecked(false);
		r1_2.setChecked(false);
		r2_1.setChecked(false);
		r2_2.setChecked(false);
		r3_1.setChecked(false);
		r3_2.setChecked(false);
		r3_3.setChecked(false);
		r4_1.setChecked(false);
		r4_2.setChecked(false);
		r4_3.setChecked(false);
		r4_4.setChecked(false);
		r4_5.setChecked(false);
		r4_6.setChecked(false);
		job_1.setChecked(false);
		job_2.setChecked(false);		
		job_3.setChecked(false);
		job_4.setChecked(false);
		job_5.setChecked(false);
		job_6.setChecked(false);
		job_7.setChecked(false);
		job_8.setChecked(false);
		job_9.setChecked(false);
		job_10.setChecked(false);;
		job_11.setChecked(false);
		job_12.setChecked(false);
		job_13.setChecked(false);
		job_14.setChecked(false);
		job_15.setChecked(false);
		job_16.setChecked(false);
		job_17.setChecked(false);
		job_18.setChecked(false);
		r5_1.setChecked(false);
		r5_2.setChecked(false);
		r5_3.setChecked(false);
		r5_4.setChecked(false);
		r6_1.setChecked(false);
		r6_2.setChecked(false);
		r7_1.setChecked(false);
		r7_2.setChecked(false);
		b1.setChecked(false);
		b2.setChecked(false);
		b3_1.setChecked(false);
		b3_2.setChecked(false);
		b3_3.setChecked(false);
		b3_4.setChecked(false);
    	b3_5.setChecked(false);
    	b4.setChecked(false);
    	b5.setChecked(false);
		b6.setChecked(false);
		b7.setChecked(false);
		b8.setChecked(false);
		b9.setChecked(false);
		b10.setChecked(false);
		b11_1.setChecked(false);
		b11_2.setChecked(false);
		b11_3.setChecked(false);
		b12_1.setChecked(false);
		b12_2.setChecked(false);
		b13_1.setChecked(false);
		b13_2.setChecked(false);
		b13_3.setChecked(false);
		b13_4.setChecked(false);
		b14_1.setChecked(false);
		b14_2.setChecked(false);
		b15.setChecked(false);
		b16.setChecked(false);
		b17.setChecked(false);
		b18.setChecked(false);
		b19.setChecked(false);
		b20.setChecked(false);
		b21.setChecked(false);
		b22_1.setChecked(false);
		b22_2.setChecked(false);
		b22_3.setChecked(false);
		b22_4.setChecked(false);
		b22_5.setChecked(false);
		b23.setChecked(false);
		b24.setChecked(false);
		b25_1.setChecked(false);
		b25_2.setChecked(false);
		b25_3.setChecked(false);
		c1.setChecked(false);
		c2.setChecked(false);
		c3.setChecked(false);
		c4.setChecked(false);
		c5.setChecked(false);
		c6.setChecked(false);
		c7.setChecked(false);
		c8.setChecked(false);
		c9.setChecked(false);
		c10.setChecked(false);
	}

	public void fetchData(){
        ep=new EpidemicRecord(Epidemic.this);//从表中检数据
		ep.selectCode(this.indiid);		
		ep.selectEpidemicRecord(this.indiid);
		System.out.println("htest.fetchData="+ep.getIndi_id());
	}
	/**
	 * 读取view的值并保存至ID对应的记录中
	 */
	public boolean saveView() {
		
		EpidemicRecord ep1 = new EpidemicRecord(Epidemic.this);
		ep1.setIndi_id(this.indiid);
		
		System.out.println("savestart=================");
		// TODO Auto-generated method stub
		if(r2_1.isChecked()==false&&r2_2.isChecked()==false){
			new AlertDialog.Builder(Epidemic.this)
            .setIcon(R.drawable.alert_dialog_icon)
            .setMessage("性别不能为空！\n所有带“*”号项目为必填项！请仔细检查!")               
            .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                	}
            }).show();
			return false;
		}
		if(et_perid.getText().toString().length()>1&&et_perid.getText().toString().length()<18){
			new AlertDialog.Builder(Epidemic.this)
            .setIcon(R.drawable.alert_dialog_icon)
            .setMessage("请输入18位身份证号!")               
            .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                	}
            }).show();
			return false;
		}
		if(et_born.getText().toString().length()<1&&et_full_born.getText().toString().length()<1){
			new AlertDialog.Builder(Epidemic.this)
            .setIcon(R.drawable.alert_dialog_icon)
            .setMessage("出生日期不能为空！\n所有带“*”号项目为必填项！请仔细检查!")               
            .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                	}
            }).show();
			return false;
		}
		if(et_full_born.getText().toString().length()>1 ){
			if(r3_2.isChecked()==false&&r3_3.isChecked()==false&&r3_1.isChecked()==false){
		
			new AlertDialog.Builder(Epidemic.this)
            .setIcon(R.drawable.alert_dialog_icon)
            .setMessage("实足年龄单位不能为空！\n所有带“*”号项目为必填项！请仔细检查!")               
            .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                	}
            }).show();
			return false;
		}
		}
		if(r4_1.isChecked()==false && r4_2.isChecked()==false&&r4_3.isChecked()==false&&r4_4.isChecked()==false&&r4_5.isChecked()==false&&r4_6.isChecked()==false){
			new AlertDialog.Builder(Epidemic.this)
            .setIcon(R.drawable.alert_dialog_icon)
            .setMessage("病人所属县区不能为空！\n所有带“*”号项目为必填项！请仔细检查!")               
            .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                	}
            }).show();
			return false;
		}
		
		if(et_town.getText().toString().length()<1){
			new AlertDialog.Builder(Epidemic.this)
            .setIcon(R.drawable.alert_dialog_icon)
            .setMessage("现住址乡不能为空！\n所有带“*”号项目为必填项！请仔细检查!")               
            .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                	}
            }).show();
			return false;
		}
		
		if(et_village.getText().toString().length()<1){
			new AlertDialog.Builder(Epidemic.this)
            .setIcon(R.drawable.alert_dialog_icon)
            .setMessage("现住址村不能为空！\n所有带“*”号项目为必填项！请仔细检查!")               
            .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                	}
            }).show();
			return false;
		}
		
		if(et_housenumber.getText().toString().length()<1){
			new AlertDialog.Builder(Epidemic.this)
            .setIcon(R.drawable.alert_dialog_icon)
            .setMessage("现住址门牌号不能为空！\n所有带“*”号项目为必填项！请仔细检查!")               
            .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                	}
            }).show();
			return false;
		}
		job();
		for(int i=0;i<18;i++){
			if(j.get(i).isChecked()==false){
				num++;
			}
		}
		if(num==18){
			new AlertDialog.Builder(Epidemic.this)
            .setIcon(R.drawable.alert_dialog_icon)
            .setMessage("患者职业不能为空！\n所有带“*”号项目为必填项！请仔细检查!")               
            .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                	}
            }).show();
			return false;
		}
		if(r5_1.isChecked()==false && r5_2.isChecked()==false&&r5_3.isChecked()==false&&r5_4.isChecked()==false){
			new AlertDialog.Builder(Epidemic.this)
            .setIcon(R.drawable.alert_dialog_icon)
            .setMessage("病例分类不能为空！\n所有带“*”号项目为必填项！请仔细检查!")               
            .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                	}
            }).show();
			return false;
		}
		if(r6_1.isChecked()==false&&r6_2.isChecked()==false){
			new AlertDialog.Builder(Epidemic.this)
            .setIcon(R.drawable.alert_dialog_icon)
            .setMessage("病例分类急、慢性不能为空！\n所有带“*”号项目为必填项！请仔细检查!")               
            .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                	}
            }).show();
			return false;
		}
		if(et_ill_date.getText().toString().length()<1){
			new AlertDialog.Builder(Epidemic.this)
            .setIcon(R.drawable.alert_dialog_icon)
            .setMessage("发病日期不能为空！\n所有带“*”号项目为必填项！请仔细检查!")               
            .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                	}
            }).show();
			return false;
		}
		if(et_diag_date.getText().toString().length()<1 | et_diag_time.getText().toString().length()<1){
			new AlertDialog.Builder(Epidemic.this)
            .setIcon(R.drawable.alert_dialog_icon)
            .setMessage("诊断日期及时间不能为空！\n所有带“*”号项目为必填项！请仔细检查!")               
            .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                	}
            }).show();
			return false;
		}
		int time=Integer.parseInt(et_diag_time.getText().toString());
		if(time>24|time<1){
			new AlertDialog.Builder(Epidemic.this)
            .setIcon(R.drawable.alert_dialog_icon)
            .setMessage("诊断时间应为0时——24时！请重新输入！")               
            .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                	et_diag_time.setText("");
                	}
            }).show();
			return false;
		}
		for(int i=0;i<54;i++){
			if(b.get(i).isChecked()==false){
				num1++;
			}
		}
		if(num1==54){
			new AlertDialog.Builder(Epidemic.this)
            .setIcon(R.drawable.alert_dialog_icon)
            .setMessage("传染病选项不能为空！\n所有带“*”号项目为必填项！请仔细检查!")               
            .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                	}
            }).show();
			return false;
		}
		
			
		String temp = "";
		temp = et_name.getText().toString();
		if(temp.length()>0){
		ep1.setIndi_name(temp);
		}
		
		temp = et_number.getText().toString();
		if(temp.length()>0){
		ep1.setIndi_id(Integer.parseInt(temp));
		}
		
		if(r1_1.isChecked()==true){
			ep1.setIndi_category(1);
		}else if(r1_2.isChecked()==true){
			ep1.setIndi_category(2);
		}
		
		temp = et_parent_name.getText().toString();
		if(temp.length()>0){
		ep1.setIndi_parent_name(temp);
		}
		
		temp = et_perid.getText().toString();
		if(temp.length()>0){
		ep1.setIndi_perid(temp);
		}
		
		if(r2_1.isChecked()==true){
			ep1.setIndi_sex(1);
		}else if(r2_2.isChecked()==true){
			ep1.setIndi_sex(2);
		}
		
		temp = et_born.getText().toString();
		if(temp.length()>0){
		ep1.setIndi_born(temp);
		}
		
		temp = et_full_born.getText().toString();
		if(temp.length()>0){
		ep1.setIndi_full_born(temp);
		}
		
		if(r3_1.isChecked()==true){
			ep1.setIndi_full_unit(1);
		}else if(r3_2.isChecked()==true){
			ep1.setIndi_full_unit(2);
		}
		 else if(r3_3.isChecked()==true){
				ep1.setIndi_full_unit(3);
		}
		
		temp = et_work.getText().toString();
		if(temp.length()>0){
		ep1.setIndi_work(temp);
		}
		
		temp = et_phone.getText().toString();
		if(temp.length()>0){
		ep1.setIndi_phone(temp);
		}
		
		if(r4_1.isChecked()==true){
			ep1.setIndi_area(1);
		}else if(r4_2.isChecked()==true){
			ep1.setIndi_area(2);
		}
		 else if(r4_3.isChecked()==true){
				ep1.setIndi_area(3);
		}
		 else if(r4_4.isChecked()==true){
				ep1.setIndi_area(4);
		}
		 else if(r4_5.isChecked()==true){
				ep1.setIndi_area(5);
		}
		 else if(r4_6.isChecked()==true){
				ep1.setIndi_area(6);
		}
		
		temp = et_province.getText().toString();
		if(temp.length()>0){
		ep1.setIndi_province(temp);		
		}
		temp = et_city.getText().toString();
		if(temp.length()>0){
		ep1.setIndi_city(temp);		
		}
		temp = et_country.getText().toString();
		if(temp.length()>0){
		ep1.setIndi_country(temp);		
		}
		temp = et_town.getText().toString();
		if(temp.length()>0){
		ep1.setIndi_town(temp);		
		}
		temp = et_village.getText().toString();
		if(temp.length()>0){
		ep1.setIndi_village(temp);		
		}
		
		
		temp = et_housenumber.getText().toString();
		if(temp.length()>0){
		ep1.setIndi_number(temp);
		}
		job();
		for(int i=0;i<18;i++){
			if(j.get(i).isChecked()==true){
				ep1.setIndi_job(i+1);
			}
		}
		
		temp = et_job_other.getText().toString();
		if(temp.length()>0){
		ep1.setIndi_job_other(temp);
		}
		
		if(r5_1.isChecked()==true){
			ep1.setIndi_classification_a(1);
		}else if(r5_2.isChecked()==true){
			ep1.setIndi_classification_a(2);
		}
		 else if(r5_3.isChecked()==true){
				ep1.setIndi_classification_a(3);
		}
		 else if(r5_4.isChecked()==true){
				ep1.setIndi_classification_a(4);
		}
		
		if(r6_1.isChecked()==true){
			ep1.setIndi_classification_b(1);
		}else if(r6_2.isChecked()==true){
			ep1.setIndi_classification_b(2);
		}
		
		temp = et_ill_date.getText().toString();
		if(temp.length()>0){
		ep1.setIndi_ill_date(temp);
		}
		
		temp = et_diag_date.getText().toString();
		if(temp.length()>0){
		ep1.setIndi_diagnose_date(temp);
		}
		temp = et_diag_time.getText().toString();
		if(temp.length()>0){
		ep1.setIndi_diagnose_time(temp);
		}
		
		temp = et_die_date.getText().toString();
		if(temp.length()>0){
		ep1.setIndi_die_date(temp);
		}
		
		for(int i=0;i<54;i++){
			if(b.get(i).isChecked()==true){
				ep1.setIndi_disease_a(i+1);
			}
		};	

		
		temp = et_other.getText().toString();
		if(temp.length()>0){
		ep1.setIndi_other(temp);
		}
		
		temp = et_disease_name.getText().toString();
		if(temp.length()>0){
		ep1.setIndi_disease_name(temp);
		}
		
		temp = et_reason.getText().toString();
		if(temp.length()>0){
		ep1.setIndi_reason(temp);
		}
		
		temp = et_orgnization.getText().toString();
		if(temp.length()>0){
		ep1.setIndi_orgnization(temp);
		}
		
		temp = et_connect_phone.getText().toString();
		if(temp.length()>0){
		ep1.setIndi_connect_phone(temp);
		}
		
		temp = et_report.getText().toString();
		if(temp.length()>0){
		ep1.setIndi_report(temp);
		}
		
		temp = et_fill_date.getText().toString();
		if(temp.length()>0){
		ep1.setIndi_fill_date(temp);
		}
		
		temp = et_remark.getText().toString();
		if(temp.length()>0){
		ep1.setIndi_remark(temp);		
		}
		ep1.updateEpidemicRecord(indiid);
		System.out.println("save_____________");		
		Toast.makeText(Epidemic.this, "该页信息已保存", Toast.LENGTH_SHORT).show();
		return true;		
	}    
	
	
	
	@Override
	public void onClick(View v) {
		job();
		if(v==et_born){
			mPopupWindow = new MyPopupWindow(Epidemic.this);			
			mPopupWindow.showAtLocation(v.findViewById(R.id.ep_born), Gravity.CENTER, 0, 0);
			Button btn=mPopupWindow.getButton();
			btn.setOnClickListener(new OnClickListener(){
				@Override
				public void onClick(View v) {
					et_born.setText(mPopupWindow.getDate());
					mPopupWindow.dismiss();
				}				
			});
		}
		
		else if(v==et_ill_date){
			mPopupWindow = new MyPopupWindow(Epidemic.this);			
			mPopupWindow.showAtLocation(v.findViewById(R.id.ep_ill_date), Gravity.CENTER, 0, 0);
			Button btn=mPopupWindow.getButton();
			btn.setOnClickListener(new OnClickListener(){
				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					et_ill_date.setText(mPopupWindow.getDate());
					mPopupWindow.dismiss();
				}				
			});
		}
		
		else if(v==et_diag_date){
			mPopupWindow = new MyPopupWindow(Epidemic.this);			
			mPopupWindow.showAtLocation(v.findViewById(R.id.ep_diag_date), Gravity.CENTER, 0, 0);
			Button btn=mPopupWindow.getButton();
			btn.setOnClickListener(new OnClickListener(){
				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					et_diag_date.setText(mPopupWindow.getDate());
					mPopupWindow.dismiss();
				}				
			});
		}
		
		else if(v==et_die_date){
			mPopupWindow = new MyPopupWindow(Epidemic.this);			
			mPopupWindow.showAtLocation(v.findViewById(R.id.ep_die_date), Gravity.CENTER, 0, 0);
			Button btn=mPopupWindow.getButton();
			btn.setOnClickListener(new OnClickListener(){
				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					et_die_date.setText(mPopupWindow.getDate());
					mPopupWindow.dismiss();
				}				
			});
		}	
		else if(v==et_full_born){
			et_born.setText("");
		}
		else if(v==et_born){
			et_full_born.setText("");
			r3_1.setChecked(false);
			r3_1.setChecked(false);
			r3_1.setChecked(false);
		}
		else if(v==leftBtn){
			new AlertDialog.Builder(Epidemic.this)
			.setIcon(R.drawable.alert_dialog_icon)
			.setTitle("您确定已经保存了要退出吗？")
			.setPositiveButton("确定", new DialogInterface.OnClickListener(){
				public void onClick(DialogInterface dialog, int whichButton) {
					Epidemic.this.finish();
					overridePendingTransition(R.anim.anim_slide_in_left,R.anim.anim_slide_out_right);
				}
			})
			.setNegativeButton("取消", new DialogInterface.OnClickListener() {
		                    public void onClick(DialogInterface dialog, int whichButton) {

		                        /* User clicked Cancel so do some stuff */
		                   }
		                })
		                .create().show();
		}
		else if(v==rightBtn){			
			saveView();
		}
		else if(v==rightBtn2){

			if(saveView()==false){
				new AlertDialog.Builder(Epidemic.this)
	            .setIcon(R.drawable.alert_dialog_icon)
	            .setTitle("提示！")
	            .setMessage("请仔细检查！查带*号项不能为空")               
	            .setPositiveButton("确定", new DialogInterface.OnClickListener() {
	                public void onClick(DialogInterface dialog, int whichButton) {
	                    	
	                	}
	            }).create().show();
							
			}

			else if(saveView()==true){							
				fetchData();
				initView();			
			new AlertDialog.Builder(Epidemic.this)
            .setIcon(R.drawable.alert_dialog_icon)
            .setTitle("提示！")
            .setMessage("该信息提交后不可修改，您是否确认提交该信息？")               
            .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
//                	en=1;
                	EpidemicRecord ep1 = new EpidemicRecord(Epidemic.this);
                    ep1.setIndi_en(1);
                    ep1.setIndi_check(0);
                    ep1.updateEN(indiid);                  
                	send();
                	check=ep1.getIndi_check();
                 System.out.println("state="+ ep1.getIndi_en())  ;            	
                	}
            }).setNegativeButton("取消",
    				new DialogInterface.OnClickListener() {
				public void onClick(DialogInterface dialog, int whichButton) {
					/* User clicked Cancel so do some stuff */
				}
			}).create().show();		
		}	
		}
		else if(v==job_1){
			for(int i=0;i<18;i++){	
				j.get(i).setChecked(false);
			}
			job_1.setChecked(true);
		}
		else if(v==job_2){			
			for(int i=0;i<18;i++){		
				j.get(i).setChecked(false);
			} 
			job_2.setChecked(true);
		}
		else if(v==job_3){			
			for(int i=0;i<18;i++){		
				j.get(i).setChecked(false);
			} 
			job_3.setChecked(true);
		}
		else if(v==job_4){			
			for(int i=0;i<18;i++){		
				j.get(i).setChecked(false);
			} 
			job_4.setChecked(true);
		}
		else if(v==job_5){			
			for(int i=0;i<18;i++){		
				j.get(i).setChecked(false);
			} 
			job_5.setChecked(true);
		}
		else if(v==job_6){			
			for(int i=0;i<18;i++){		
				j.get(i).setChecked(false);
			} 
			job_6.setChecked(true);
		}
		else if(v==job_7){			
			for(int i=0;i<18;i++){		
				j.get(i).setChecked(false);
			} 
			job_7.setChecked(true);
		}
		else if(v==job_8){			
			for(int i=0;i<18;i++){		
				j.get(i).setChecked(false);
			} 
			job_8.setChecked(true);
		}
		else if(v==job_9){			
			for(int i=0;i<18;i++){		
				j.get(i).setChecked(false);
			} 
			job_9.setChecked(true);
		}
		else if(v==job_10){
			for(int i=0;i<18;i++){		
				j.get(i).setChecked(false);
			} 
			job_10.setChecked(true);
		}
		else if(v==job_11){			
			for(int i=0;i<18;i++){		
				j.get(i).setChecked(false);
			} 
			job_11.setChecked(true);
		}
		else if(v==job_12){			
			for(int i=0;i<18;i++){		
				j.get(i).setChecked(false);
			} 
			job_12.setChecked(true);
		}
		else if(v==job_13){
			for(int i=0;i<18;i++){		
				j.get(i).setChecked(false);
			} 
			job_13.setChecked(true);
		}
		else if(v==job_14){
			for(int i=0;i<18;i++){		
				j.get(i).setChecked(false);
			} 
			job_14.setChecked(true);
		}
		else if(v==job_15){
			for(int i=0;i<18;i++){		
				j.get(i).setChecked(false);
			} 
			job_15.setChecked(true);
		}
		else if(v==job_16){
			for(int i=0;i<18;i++){		
				j.get(i).setChecked(false);
			} 
			job_16.setChecked(true);
		}
		else if(v==job_17){
			for(int i=0;i<18;i++){		
				j.get(i).setChecked(false);
			} 
			job_17.setChecked(true);
		}
		else if(v==job_18){
			for(int i=0;i<18;i++){		
				j.get(i).setChecked(false);
			} 
			job_18.setChecked(true);
		}
		else if(v==et_job_other){
			for(int i=0;i<18;i++){		
				j.get(i).setChecked(false);
			} 
			job_17.setChecked(true);			
		}
		else if(v==r7_1){
			
			for(int i=0;i<54;i++){	
				b.get(i).setChecked(false);
			}
			r7_1.setChecked(true);
		}
		else if(v==r7_2){			
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			r7_2.setChecked(true);
		}
		else if(v==b1){			
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b1.setChecked(true);
		}
		else if(v==b2){			
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b2.setChecked(true);
		}
		else if(v==b3_1){			
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b3_1.setChecked(true);
		}
		else if(v==b3_2){			
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b3_2.setChecked(true);
		}
		else if(v==b3_3){			
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b3_3.setChecked(true);
		}
		else if(v==b3_4){			
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b3_4.setChecked(true);
		}
		else if(v==b3_5){			
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b3_5.setChecked(true);
		}
		else if(v==b4){			
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b4.setChecked(true);
		}
		else if(v==b5){			
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b5.setChecked(true);
		}
		else if(v==b6){			
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b6.setChecked(true);
		}
		else if(v==b7){			
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b7.setChecked(true);
		}
		else if(v==b8){			
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b8.setChecked(true);
		}
		else if(v==b9){			
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b9.setChecked(true);
		}
		else if(v==b10){
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b10.setChecked(true);
		}
		else if(v==b11_1){			
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b11_1.setChecked(true);
		}
		else if(v==b11_2){			
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b11_2.setChecked(true);
		}
		else if(v==b11_3){			
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b11_3.setChecked(true);
		}
		else if(v==b12_1){			
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b12_1.setChecked(true);
		}
		else if(v==b12_2){			
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b12_2.setChecked(true);
		}
		else if(v==b13_1){
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b13_1.setChecked(true);
		}
		else if(v==b13_1){
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b13_1.setChecked(true);
		}
		else if(v==b13_2){
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b13_2.setChecked(true);
		}
		else if(v==b13_3){
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b13_3.setChecked(true);
		}
		else if(v==b13_4){
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b13_4.setChecked(true);
		}
		else if(v==b14_1){
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b14_1.setChecked(true);
		}
		else if(v==b14_2){
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b14_2.setChecked(true);
		}
		else if(v==b15){
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b15.setChecked(true);
		}
		else if(v==b16){
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b16.setChecked(true);
		}
		else if(v==b17){
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b17.setChecked(true);
		}
		else if(v==b18){
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b18.setChecked(true);
		}
		else if(v==b19){
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b19.setChecked(true);
		}
		else if(v==b20){
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b20.setChecked(true);
		}
		else if(v==b21){
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b21.setChecked(true);
		}
		else if(v==b22_1){
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b22_1.setChecked(true);
		}
		else if(v==b22_2){
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b22_2.setChecked(true);
		}
		else if(v==b22_3){
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b22_3.setChecked(true);
		}
		else if(v==b22_4){
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b22_4.setChecked(true);
		}
		else if(v==b22_5){
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b22_5.setChecked(true);
		}
		else if(v==b23){
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b23.setChecked(true);
		}
		else if(v==b24){
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b24.setChecked(true);
		}
		else if(v==b25_1){
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b25_1.setChecked(true);
		}
		else if(v==b25_2){
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b25_2.setChecked(true);
		}
		else if(v==b25_3){
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			b25_3.setChecked(true);
		}
		else if(v==c1){
			for(int i=0;i<54;i++){	
				b.get(i).setChecked(false);
			}
			c1.setChecked(true);
		}
		else if(v==c2){			
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			c2.setChecked(true);
		}
		else if(v==c3){			
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			c3.setChecked(true);
		}
		else if(v==c4){			
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			c4.setChecked(true);
		}
		else if(v==c5){			
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			c5.setChecked(true);
		}
		else if(v==c6){			
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			c6.setChecked(true);
		}
		else if(v==c7){			
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			c7.setChecked(true);
		}
		else if(v==c8){			
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			c8.setChecked(true);
		}
		else if(v==c9){			
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			c9.setChecked(true);
		}
		else if(v==c10){
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
			c10.setChecked(true);
		}		
		else if(v==et_other){
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 			
		}		
    }
	
	 public void send() 
		{ 
	    	JSONObject data= new JSONObject();
	    	  try{
	    		  data.put("卡片编号",id);
	    		  data.put("报卡类别", category);
	    		  data.put("姓名", name);
	    		  data.put("患儿家长姓名", paraentname);
	    		  data.put("身份证号",perid );
	    		  data.put("性别", sex);
	    		  data.put("出生日期",born );
	    		  data.put("实足年龄",fullborn );
	    		  data.put("实足年龄单位",fullunit);
	    		  data.put("工作单位",workunit );
	    		  data.put("联系电话", phone);
	    		  data.put("病人属于",area );
	    		  data.put("现住址省",province );
	    		  data.put("市", city);
	    		  data.put("县", country);
	    		  data.put("乡",town );
	    		  data.put("村",village );
	    		  data.put("门牌号",housenumber );
	    		  data.put("职业",job );
	    		  data.put("其他职业", job_other);
	    		  data.put("病例分类（1）",classification_a );
	    		  data.put("病例分类（2）", classification_b);
	    		  data.put("发病日期",illdate );
	    		  data.put("诊断日期", diagdate);
	    		  data.put("诊断时间", diagtime);
	    		  data.put("死亡日期",diedate );
	    		  data.put("传染病类型", disease_a);
	    		  data.put("其他传染病",other );
	    		  data.put("订正病名", illname);
	    		  data.put("退卡原因",reason );
	    		  data.put("报告单位", unit);
	    		  data.put("报告人联系电话",connect_phone );
	    		  data.put("报告医生",report );
	    		  data.put("填卡日期", filldate);
	    		  data.put("备注", remark);
//	    		  data.put("控件不可用",en);
	    		  data.put("提交状态", check);
	    		  
	    	  }catch (JSONException e) {
	              // TODO Auto-generated catch block
	              e.printStackTrace();
	      }
	         String r_data=data.toString();
	         System.out.println(r_data);
			try {
				String pathUrl = "http://202.201.12.43/Disease/receive";
//				String pathUrl = "http://202.201.12.218:8080/HttpService/today_old.jsp";
				URL url = new URL(pathUrl);
				System.out.println("success-7");
				HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
				System.out.println("success-8");
				httpConn.setDoOutput(true);
				httpConn.setDoInput(true);
				httpConn.setUseCaches(false);
				httpConn.setRequestMethod("POST");
				System.out.println("success-0");

				byte []requestStringBytes=r_data.getBytes();
				httpConn.setRequestProperty("Content-length", "" + requestStringBytes.length);
				httpConn.setRequestProperty("Content-Type", "application/octet-stream");
				httpConn.setRequestProperty("Connection", "Keep-Alive");// ά�ֳ�����
				httpConn.setRequestProperty("Charset", "UTF-8");				
				String name = URLEncoder.encode("chen", "utf-8");
				httpConn.setRequestProperty("NAME", name);						
				System.out.println("success-1");
				OutputStream outputStream=httpConn.getOutputStream();
				System.out.println("success-2");
				outputStream.write(requestStringBytes);
				System.out.println("success-3");
				outputStream.flush();
				System.out.println("success-4");
				outputStream.close();	
				//�����Ӧ״̬
				int responseCode = httpConn.getResponseCode();
				System.out.println("HttpURLConnection.HTTP_OK="+HttpURLConnection.HTTP_OK);
				System.out.println("responseCode="+responseCode);
				if (HttpURLConnection.HTTP_OK == responseCode) 
				{
			}
				httpConn.disconnect();
				Toast toast = Toast.makeText(getApplicationContext(), "发送成功", Toast.LENGTH_LONG);
				toast.show();
			} catch (Exception ex) 
			{
				Toast toast = Toast.makeText(getApplicationContext(), "发送失败", Toast.LENGTH_LONG);
				toast.show();
				ex.printStackTrace();
			}
			
			enable();
			
		}
	
	public void job(){
		j= new ArrayList<RadioButton>();
		j.add(job_1);
        j.add(job_2);
        j.add(job_3);
        j.add(job_4);
        j.add(job_5);
        j.add(job_6);
        j.add(job_7);
        j.add(job_8);
        j.add(job_9);
        j.add(job_10);
		j.add(job_11);
		j.add(job_12);
		j.add(job_13);
		j.add(job_14);
		j.add(job_15);
		j.add(job_16);
		j.add(job_17);
		j.add(job_18);
	}
	
	public void disease(){
		b= new ArrayList<RadioButton>();
		b.add(r7_1);
		b.add(r7_2);
		b.add(b1);
        b.add(b2);
        b.add(b3_1);
        b.add(b3_2);
        b.add(b3_3);
        b.add(b3_4);
        b.add(b3_5);
        b.add(b4);
        b.add(b5);
        b.add(b6);
        b.add(b7);
        b.add(b8);
        b.add(b9);
        b.add(b10);
		b.add(b11_1);
		b.add(b11_2);
		b.add(b11_3);
		b.add(b12_1);
		b.add(b12_2);
		b.add(b13_1);
		b.add(b13_2);
		b.add(b13_3);
		b.add(b13_4);
		b.add(b14_1);
		b.add(b14_2);;
		b.add(b15);
		b.add(b16);
		b.add(b17);
		b.add(b18);
		b.add(b19);
		b.add(b20);
		b.add(b21);
		b.add(b22_1);
		b.add(b22_2);
		b.add(b22_3);
		b.add(b22_4);
		b.add(b22_5);
		b.add(b23);
		b.add(b24);
		b.add(b25_1);
		b.add(b25_2);
		b.add(b25_3);
		b.add(c1);
		b.add(c2);
		b.add(c3);
		b.add(c4);
		b.add(c5);
		b.add(c6);
		b.add(c7);
		b.add(c8);
		b.add(c9);
		b.add(c10);		
	}
	
	public void enable(){
		et_number.setEnabled(false);
		et_name.setEnabled(false);
		et_province.setEnabled(false);
		et_city.setEnabled(false);
		et_country.setEnabled(false);
		et_town.setEnabled(false);
		et_village.setEnabled(false);
		et_parent_name.setEnabled(false);
		et_perid.setEnabled(false);
		et_born.setEnabled(false);
		et_full_born.setEnabled(false);
		et_work .setEnabled(false);
		et_phone.setEnabled(false);
		et_housenumber.setEnabled(false);
        et_job_other.setEnabled(false);
		et_ill_date.setEnabled(false);
		et_diag_date.setEnabled(false);
		et_diag_time.setEnabled(false);
		et_die_date.setEnabled(false);
		et_other.setEnabled(false);
		et_disease_name.setEnabled(false);
		et_reason.setEnabled(false);
		et_orgnization.setEnabled(false);
		et_connect_phone.setEnabled(false);
		et_report.setEnabled(false);
		et_fill_date.setEnabled(false);
		et_remark.setEnabled(false);
		r1.setEnabled(false);
		r2.setEnabled(false);
		r3.setEnabled(false);
		r4.setEnabled(false);
		r5.setEnabled(false);
		r6.setEnabled(false);
		r1_1.setEnabled(false);
		r1_2.setEnabled(false);
		r2_1.setEnabled(false);
		r2_2.setEnabled(false);
		r3_1.setEnabled(false);
		r3_2.setEnabled(false);
		r3_3.setEnabled(false);
		r4_1.setEnabled(false);
		r4_2.setEnabled(false);
		r4_3.setEnabled(false);
		r4_4.setEnabled(false);
		r4_5.setEnabled(false);
		r4_6.setEnabled(false);
		job_1.setEnabled(false);
		job_1.setEnabled(false);
		job_2.setEnabled(false);
		job_2.setEnabled(false);
		job_3.setEnabled(false);
		job_4.setEnabled(false);
		job_5.setEnabled(false);
		job_6.setEnabled(false);
		job_7.setEnabled(false);
		job_8.setEnabled(false);
		job_9.setEnabled(false);
		job_10.setEnabled(false);
		job_11.setEnabled(false);
		job_12.setEnabled(false);
		job_13.setEnabled(false);
		job_14.setEnabled(false);
		job_15.setEnabled(false);
		job_16.setEnabled(false);
		job_17.setEnabled(false);
		job_18.setEnabled(false);
		r5_1.setEnabled(false);
		r5_2.setEnabled(false);
		r5_3.setEnabled(false);
		r5_4.setEnabled(false);
		r6_1.setEnabled(false);
		r6_2.setEnabled(false);
		r7_1.setEnabled(false);
		r7_2.setEnabled(false);
		b1.setEnabled(false);
		b2.setEnabled(false);
		b3_1.setEnabled(false);
		b3_2.setEnabled(false);
		b3_3.setEnabled(false);
		b3_4.setEnabled(false);
		b3_5.setEnabled(false);
		b4.setEnabled(false);
		b5.setEnabled(false);
		b6.setEnabled(false);
		b7.setEnabled(false);
		b8.setEnabled(false);
		b9.setEnabled(false);
		b10.setEnabled(false);
		b11_1.setEnabled(false);
		b11_2.setEnabled(false);
		b11_3.setEnabled(false);
		b12_1.setEnabled(false);
		b12_2.setEnabled(false);;
		b13_1.setEnabled(false);
		b13_2.setEnabled(false);
		b13_3.setEnabled(false);
		b13_4.setEnabled(false);
		b14_1.setEnabled(false);
		b14_2.setEnabled(false);
		b15.setEnabled(false);
		b16.setEnabled(false);
		b17.setEnabled(false);
		b18.setEnabled(false);
		b19.setEnabled(false);
		b20.setEnabled(false);
		b21.setEnabled(false);
		b22_1.setEnabled(false);
		b22_2.setEnabled(false);;
		b22_3.setEnabled(false);
		b22_4.setEnabled(false);
		b22_5.setEnabled(false);
		b23.setEnabled(false);
		b24.setEnabled(false);
		b25_1.setEnabled(false);
		b25_2.setEnabled(false);
		b25_3.setEnabled(false);
		c1.setEnabled(false);
		c2.setEnabled(false);
		c3.setEnabled(false);
		c4.setEnabled(false);
		c5.setEnabled(false);
		c6.setEnabled(false);
		c7.setEnabled(false);
		c8.setEnabled(false);
		c9.setEnabled(false);
		c10.setEnabled(false);
		
	}
	public void onFocusChange(View v, boolean hasFocus) {
		
		
		
		
		
		
			// TODO Auto-generated method stub
			if(v==et_born&&hasFocus){
				mPopupWindow = new MyPopupWindow(getBaseContext());			
				mPopupWindow.showAtLocation(findViewById(R.id.ep_born), Gravity.CENTER, 0, 0);

				Button btn=mPopupWindow.getButton();
				btn.setOnClickListener(new OnClickListener(){

					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						et_born.setText(mPopupWindow.getDate());
						mPopupWindow.dismiss();
					}
					
				});
			}
			if(v==et_ill_date&&hasFocus){
				mPopupWindow = new MyPopupWindow(getBaseContext());			
				mPopupWindow.showAtLocation(findViewById(R.id.ep_ill_date), Gravity.CENTER, 0, 0);

				Button btn=mPopupWindow.getButton();
				btn.setOnClickListener(new OnClickListener(){

					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						et_ill_date.setText(mPopupWindow.getDate());
						mPopupWindow.dismiss();
					}
					
				});
			}
			if(v==et_diag_date&&hasFocus){
				mPopupWindow = new MyPopupWindow(getBaseContext());			
				mPopupWindow.showAtLocation(findViewById(R.id.ep_diag_date), Gravity.CENTER, 0, 0);

				Button btn=mPopupWindow.getButton();
				btn.setOnClickListener(new OnClickListener(){

					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						et_diag_date.setText(mPopupWindow.getDate());
						mPopupWindow.dismiss();
					}
					
				});
			}
			if(v==et_die_date&&hasFocus){
				mPopupWindow = new MyPopupWindow(getBaseContext());			
				mPopupWindow.showAtLocation(findViewById(R.id.ep_die_date), Gravity.CENTER, 0, 0);

				Button btn=mPopupWindow.getButton();
				btn.setOnClickListener(new OnClickListener(){

					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						et_die_date.setText(mPopupWindow.getDate());
						mPopupWindow.dismiss();
					}
					
				});
			}
		
		
		
		
		job();
		if(v==et_job_other&&hasFocus){
			for(int i=0;i<18;i++){		
				j.get(i).setChecked(false);
			} 
			job_17.setChecked(true);			
		}
		else if(v==et_other&&hasFocus){
			for(int i=0;i<54;i++){		
				b.get(i).setChecked(false);
			} 
		}	
		else if(v==et_full_born&&hasFocus){
			et_born.setText("");
		}
		else if(v==et_born&&hasFocus){
			et_full_born.setText("");
			r3_1.setChecked(false);
			r3_2.setChecked(false);
			r3_3.setChecked(false);
		}
	}
	public class myThread extends Thread{  
		private Handler handler;
		private String str;
		private int state;
		public myThread(Handler handler,String s,int state){
			this.handler=handler;
			this.str=s;
			this.state=state;
		}
		
		public void run(){  
	        try  
	        {   
	        	Looper.getMainLooper();
	        	sleep(400); 
	        	Message msg = handler.obtainMessage();
	        	if(state==1){
	        		fetchData();
	        		msg.what=1;
			}  
	        	 	        	
	        	handler.sendMessage(msg); 
	        }
		    catch (Exception e)  
		    {  
		        e.printStackTrace();  
		    }  
		}  
	}
	
	private final Handler handler = new Handler(Looper.getMainLooper()) {
    	public void handleMessage(Message msg) { // 处理Message，更新卡片 
    		if(msg.what==1){
    			initView();
    		}
    	   mpDialog.cancel();
    		}
	};
	
	
}
	